package jee.boot.oauth.standard.dao;

import jee.boot.entity.auth.StandardModel;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

/**
 * 标准模型数据交互
 */
@Mapper
public interface StandardModelDao{
    /**
     * 获取单条数据
     *
     * @param entity
     * @return
     */
    @Select("${getSql}")
    Map<String,Object> get(StandardModel entity);

    /**
     * 查询数据列表
     *
     * @param entity
     * @return
     */
    @Select("<script>${findListSql} <where> <if test=\"where !=null and where !=''\"> ${where} </if> </where> <choose> <when test=\"page !=null and page.orderBySql != null and page.orderBySql != ''\"> ORDER BY ${page.orderBySql} </when> <otherwise></otherwise> </choose></script>")
    List<Map<String,Object>> findList(StandardModel entity);

    /**
     * 插入数据
     *
     * @param entity
     * @return
     */
    @Insert("${insertSql}")
    int insert(StandardModel entity);

    /**
     * 更新数据
     *
     * @param entity
     * @return
     */
    @Update("${updateSql}")
    int update(StandardModel entity);
    /**
     * 删除数据
     *
     * @param entity
     * @return
     */
    @Delete("${deleteSql}")
    int delete(StandardModel entity);
}
